package com.banmao.mall.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class ShiroMd5Util {
    // 添加用户的密码加密
    public static String SysMd5(String username, String password) {
        String hasAlgorithmName = "MD5";    // 加密方法

        Object crdentials = password;   // 密码原值

        ByteSource salt = ByteSource.Util.bytes(username);  // 以账号名作为盐值

        int hashIterations = 1024;  // 加密1024次

        SimpleHash hash = new SimpleHash(hasAlgorithmName, crdentials, salt, hashIterations);

        return hash.toString();
    }
}
